---
page_title: "cloudflare_worker_route Resource - Cloudflare"
subcategory: ""
description: |-
  Provides a Cloudflare worker route resource. A route will also require a cloudflare_worker_script.
---

# cloudflare_worker_route (Resource)

Provides a Cloudflare worker route resource. A route will also require a `cloudflare_worker_script`.

## Example Usage

```terraform
# Runs the specified worker script for all URLs that match `example.com/*`
resource "cloudflare_worker_route" "my_route" {
  zone_id     = "0da42c8d2132a9ddaf714f9e7c920711"
  pattern     = "example.com/*"
  script_name = cloudflare_worker_script.my_script.name
}

resource "cloudflare_worker_script" "my_script" {
  # see "cloudflare_worker_script" documentation ...
}
```
<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `pattern` (String) The [route pattern](https://developers.cloudflare.com/workers/about/routes/) to associate the Worker with.
- `zone_id` (String) The zone identifier to target for the resource. **Modifying this attribute will force creation of a new resource.**

### Optional

- `script_name` (String) Worker script name to invoke for requests that match the route pattern.

### Read-Only

- `id` (String) The ID of this resource.

## Import

Import is supported using the following syntax:

```shell
$ terraform import cloudflare_worker_route.example <zone_id>/<route_id>
```
